home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / SICL / data1.cab / sicl32 / c / samples / misc / nonfmt.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-02  |  1.3 KB  |  52 lines

  1. /* nonfmt.c
  2.    This example program measures AC voltage on a multimeter and 
  3.    prints out the results*/ 
  4.  
  5. #include <sicl.h>
  6. #include <stdio.h>
  7.  
  8. main()
  9. {
  10.    INST dvm;
  11.    char strres[20];
  12.    unsigned long actual;
  13.  
  14.    #if defined(__BORLANDC__) && !defined(__WIN32__)
  15.       _InitEasyWin();   /* required for Borland EasyWin programs */
  16.    #endif
  17.    
  18.    /* Log message and terminate on error */
  19.    ionerror (I_ERROR_EXIT);
  20.  
  21.    /* Open the multimeter session */
  22.    dvm = iopen ("hpib7,16");
  23.    itimeout (dvm, 10000);
  24.  
  25.    /*Initialize dvm*/
  26.    iwrite (dvm, "*RST\n", 5, 1, NULL);
  27.  
  28.    /*Set up multimeter and take measurements*/ 
  29.    iwrite (dvm,"CALC:DBM:REF 50\n",16,1,NULL); 
  30.    iwrite (dvm,"MEAS:VOLT:AC? 1, 0.001\n",23,1,NULL);
  31.  
  32.    /* Read measurements */
  33.    iread (dvm, strres, 20, NULL, &actual);
  34.  
  35.    /* NULL terminate result string and print the results */
  36.    /* This technique assumes the last byte sent was a line-feed */
  37.    if (actual) {
  38.      strres[actual - 1] = (char) 0;
  39.      printf("Result is %s\n", strres);
  40.    }
  41.  
  42.   /* Close the multimeter session */
  43.   iclose(dvm);
  44.   
  45.   /* For WIN16 programs, call _siclcleanup before exiting to release
  46.      resources allocated by SICL for this application.  This call
  47.      is a no-op for WIN32 programs.  */
  48.   _siclcleanup();
  49.  
  50.   return 0; 
  51. }
  52.